<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 合并数组
    var merge = function (nums1, nums2) {
      const arr = []
      for (let i = 0; i < nums2.length; i++) {
        for (let j = 0; j < nums1.length; j++) {
          if (nums2[i] < nums1[j]) {
          if (nums2[i] <= nums1[j]) {
            nums1.splice(j, 0, nums2[i])
            nums2.splice(i, 1)
            j++
          }
        }
        if (nums2[i]) {
          nums1.push(nums2[i])
        }
      }}
      console.log(nums1)
    }
    merge([1, 2, 3], [2, 5, 6])
    merge([1], [])
    merge([2, 3], [1])
  </script>
</body>
</html>